package com.bsoft.ecommerce.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: e-commerce-springclound
 * @description:
 * @author: hdh
 * @create: 2022:06:07 17:42
 */

@Slf4j
@Service
public class NacosClientService {
    @Autowired
    private final DiscoveryClient discoveryClient;

    public NacosClientService(DiscoveryClient discoveryClient) {
        this.discoveryClient = discoveryClient;
    }

    public List<ServiceInstance> getList(String serviceId) {
        log.info("nacos id" + serviceId);
        return discoveryClient.getInstances(serviceId);
    }
}
